package com.meng.ioc_demo;

import android.os.Bundle;
import android.support.annotation.Nullable;

import com.meng.baselibrary.ExceptionCrashHandler;
import com.meng.baselibrary.activity.BaseActivity;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by Administrator on 2017/5/4.
 */

public class WelcomeAty extends BaseActivity{
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setContentView() {
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        initCarchFile();
        new Thread(){
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                startActivity(MainActivity.class);
                finish();
            }
        }.start();


    }
    private void initCarchFile(){
        //获取三次的崩溃信息上传到服务器
        File crashFile = ExceptionCrashHandler.getInstance()
                .getCrashFile();
        if(crashFile.exists()){
            //上传到服务器
            try {
                InputStreamReader isr = new InputStreamReader(new FileInputStream(crashFile));
                char[] buff = new char[1024];
                int len;
                StringBuffer sb = new StringBuffer();
                while((len = isr.read(buff)) != -1){
                    String str = new String(buff,0,len);
                    sb.append(str);
                }
                isr.close();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }



}
